import uuid

import requests

# 本地环境
url = "http://localhost:4000/rpc"


def sent_text_msg(webhook_url):
    payload = {
        "jsonrpc": "2.0",
        "method": "send_win_xin_text_msg",
        "params": {
            "webhook_url": webhook_url,
            "msg": "测试消息"
        },
        "id": str(uuid.uuid4())
    }
    # 发送请求
    response = requests.post(url, json=payload).json()
    print(response)


def sent_markdown_msg(webhook_url):
    msg = "### 【任务领取通知】" \
          "\n\n尊敬的清洁同事：" \
          "\n\n您好！新的客房清洁任务已发布，请及时点击下方链接领取您的任务：" \
          "\n\n[立即领取任务](https://www.baidu.com/)" \
          "\n\n如需协助，请联系主管张经理：138-XXXX-XXXX。感谢您的配合！" \
          "\n\n<font color='red'>**酒店管理部**</font>"
    payload = {
        "jsonrpc": "2.0",
        "method": "sent_win_xin_markdown_msg",
        "params": {
            "webhook_url": webhook_url,
            "msg": msg
        },
        "id": str(uuid.uuid4())
    }
    # 发送请求
    response = requests.post(url, json=payload).json()
    print(response)


if __name__ == '__main__':
    # 测试组织
    sent_markdown_msg("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=***")
